#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i(a);i<=(b);++i)
#define req(i,a,b) for(int i(a);i>=(b);--i)
#define sort stable_sort
using namespace std;
char buf[1<<23],*p1=buf,*p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template<typename TP> inline TP read(TP &num)
{
	TP x=0;
	int f=0;
	char ch=getchar();
	while(ch<48||ch>57) f|=ch=='-',ch=getchar();
	while(48<=ch&&ch<=57) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return num=f?-x:x;
}
template<typename ...Args> inline void read(Args &...args)
{
	(read(args),...);
}
template<typename TP> inline void write(TP x)
{
	(x<0)?(putchar('-'),x=-x):0;
	(x>9)?(write(x/10),0):0;
	putchar((x%10)^48);
}
template<typename TP> inline void writeln(TP x)
{
	write<TP>(x);
	puts("");
}
constexpr int mod=998244353;
int n,m,dam[21],cnt[21],mx,ans,pre[21],dp[21][6001],pw[6001];
vector<int> tot;
inline int qpow(int x,int y)
{
	int res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod,y>>=1;
	}
	return res;
}
void dfs(int cur,int prod,int ch)
{
	if(pre[n]-pre[cur-1]+ch<m) return;
	if(ch>m) return;
	if(cur>n) return ans=(ans+(ch==m?prod:0))%mod,void();
	int nprod=prod;
	rep(i,0,cnt[cur]) dfs(cur+1,nprod,ch+i),nprod=nprod*dam[cur]%mod;
}
signed main()
{
	freopen("yt.in","r",stdin);
	freopen("yt.out","w",stdout);
	read(n,m);
	rep(i,1,n) read(dam[i],cnt[i]),mx=max(mx,cnt[i]);
	partial_sum(cnt+1,cnt+n+1,pre+1);
	if(n==1) return writeln(qpow(dam[1],m)),0;
	else if(mx<=2) return dfs(1,1,0),writeln(ans),0;
	else if(n==2)
	{
		if(cnt[1]>cnt[2]) swap(cnt[1],cnt[2]),swap(dam[1],dam[2]);
		int l=max(m-cnt[2],0ll),r=min(m,cnt[1]);
		int frac=dam[1]*qpow(dam[2],mod-2)%mod,ans=qpow(dam[2],m)*qpow(frac,l)%mod*(qpow(frac,r-l+1)-1)%mod*qpow(frac-1,mod-2)%mod;
		writeln((ans+mod)%mod);
	}
	else
	{
		dp[0][0]=1;
		rep(i,1,n)
		{
			int tot=min(m,cnt[i]); pw[0]=1;
			rep(j,1,tot) pw[j]=pw[j-1]*dam[i]%mod;
			rep(j,0,m) rep(k,0,min(j,tot)) dp[i][j]=(dp[i][j]+dp[i-1][j-k]*pw[k])%mod;
		}
		writeln(dp[n][m]);
	}
	return 0;
}
